/*
 * @lc app=leetcode.cn id=392 lang=javascript
 *
 * [392] 判断子序列
 */

// @lc code=start
/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
var isSubsequence = function(s, t) {
    let len=s.length
    let len2=t.length
    let temp=0
    let j=0
    if(len2<len){return false}
    for( i=0;i<len;i++){
        for(;temp< len2;temp++ ){
            if(s[i]==t[temp]){
                temp++
                j++
                break
            }
            if(temp==len2-1){return false}
        }
    }
    if(j!=len)return false
    return true 
};//还可用递归和快慢指针
// @lc code=end

isSubsequence("abc","ahbgdc")